]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Fallback to using a generic when requested image isn't found
authorWilliam Jon McCann <jmccann@redhat.com>
Thu, 17 Mar 2011 02:27:04 +0000 (22:27 -0400)
committerWilliam Jon McCann <jmccann@redhat.com>
Thu, 17 Mar 2011 18:02:04 +0000 (14:02 -0400)
Use a type specific generic image when the requested icon
can't be loaded instead of using an empty texture.

https://bugzilla.gnome.org/show_bug.cgi?id=644668

src/shell-app-system.c
src/shell-app.c
src/st/st-texture-cache.c

index 9012540a2ec69474feb9945789e806b47d20c346..086cfc888f0417ea0bd720660931027ecd618de1 100644 (file)
@@ -1208,21 +1208,27 @@ shell_app_info_create_icon_texture (ShellAppInfo *info, float size)
   GIcon *icon;
   ClutterActor *ret;
 
+  ret = NULL;
+
   if (info->type == SHELL_APP_INFO_TYPE_WINDOW)
     {
-      return st_texture_cache_bind_pixbuf_property (st_texture_cache_get_default (),
-                                                    G_OBJECT (info->window),
-                                                    "icon");
+      ret = st_texture_cache_bind_pixbuf_property (st_texture_cache_get_default (),
+                                                   G_OBJECT (info->window),
+                                                   "icon");
     }
-
-  icon = shell_app_info_get_icon (info);
-  if (icon == NULL)
+  else
     {
-      ret = clutter_texture_new ();
-      g_object_set (ret, "opacity", 0, "width", size, "height", size, NULL);
+      icon = shell_app_info_get_icon (info);
+      if (icon != NULL)
+        {
+          ret = st_texture_cache_load_gicon (st_texture_cache_get_default (), NULL, icon, (int)size);
+          g_object_unref (icon);
+        }
     }
-  else
+
+  if (ret == NULL)
     {
+      icon = g_themed_icon_new ("application-x-executable");
       ret = st_texture_cache_load_gicon (st_texture_cache_get_default (), NULL, icon, (int)size);
       g_object_unref (icon);
     }
index b27ebe6ba92f54831a5f23576ded8ffcd1ce2ce9..d3b00cff22dd1647d7e5cf9ef6cedec321443801 100644 (file)
@@ -141,14 +141,26 @@ shell_app_create_faded_icon_cpu (StTextureCache *cache,
   app = data->app;
   size = data->size;
 
+  info = NULL;
+
   icon = shell_app_info_get_icon (app->info);
-  if (icon == NULL)
-    return COGL_INVALID_HANDLE;
+  if (icon != NULL)
+    {
+      info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (),
+                                             icon, (int) (size + 0.5),
+                                             GTK_ICON_LOOKUP_FORCE_SIZE);
+      g_object_unref (icon);
+    }
+
+  if (info == NULL)
+    {
+      icon = g_themed_icon_new ("application-x-executable");
+      info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (),
+                                             icon, (int) (size + 0.5),
+                                             GTK_ICON_LOOKUP_FORCE_SIZE);
+      g_object_unref (icon);
+    }
 
-  info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (),
-                                         icon, (int) (size + 0.5),
-                                         GTK_ICON_LOOKUP_FORCE_SIZE);
-  g_object_unref (icon);
   if (info == NULL)
     return COGL_INVALID_HANDLE;
 
index 198ddf2734d3167b45a8192a105832f3705141d4..8b46355a7d7efdb11450a9ec65a8059563078ffd 100644 (file)
@@ -1195,6 +1195,8 @@ load_gicon_with_colors (StTextureCache    *cache,
        g_slist_free (request->textures);
        g_free (request);
        g_hash_table_remove (cache->priv->outstanding_requests, key);
+       g_object_unref (texture);
+       texture = NULL;
     }
 
   g_free (key);
@@ -1216,7 +1218,7 @@ load_gicon_with_colors (StTextureCache    *cache,
  * This will load @icon as a full-color icon; if you want a symbolic
  * icon, you must use st_texture_cache_load_icon_name().
  *
- * Return Value: (transfer none): A new #ClutterActor for the icon
+ * Return Value: (transfer none): A new #ClutterActor for the icon, or %NULL if not found
  */
 ClutterActor *
 st_texture_cache_load_gicon (StTextureCache    *cache,
@@ -1461,10 +1463,27 @@ st_texture_cache_load_icon_name (StTextureCache    *cache,
   switch (icon_type)
     {
     case ST_ICON_APPLICATION:
+      themed = g_themed_icon_new (name);
+      texture = load_gicon_with_colors (cache, themed, size, NULL);
+      g_object_unref (themed);
+      if (texture == NULL)
+        {
+          themed = g_themed_icon_new ("application-x-executable");
+          texture = load_gicon_with_colors (cache, themed, size, NULL);
+          g_object_unref (themed);
+        }
+      return CLUTTER_ACTOR (texture);
+      break;
     case ST_ICON_DOCUMENT:
       themed = g_themed_icon_new (name);
       texture = load_gicon_with_colors (cache, themed, size, NULL);
       g_object_unref (themed);
+      if (texture == NULL)
+        {
+          themed = g_themed_icon_new ("x-office-document");
+          texture = load_gicon_with_colors (cache, themed, size, NULL);
+          g_object_unref (themed);
+        }
 
       return CLUTTER_ACTOR (texture);
       break;
@@ -1482,6 +1501,12 @@ st_texture_cache_load_icon_name (StTextureCache    *cache,
       themed = g_themed_icon_new_with_default_fallbacks (name);
       texture = load_gicon_with_colors (cache, themed, size, NULL);
       g_object_unref (themed);
+      if (texture == NULL)
+        {
+          themed = g_themed_icon_new ("image-missing");
+          texture = load_gicon_with_colors (cache, themed, size, NULL);
+          g_object_unref (themed);
+        }
 
       return CLUTTER_ACTOR (texture);
       break;